import { axios as request  } from '@/utils/request'
import { encrypt } from '@/utils/rsaEncrypt'

export function getList({params}) {
  return request({
    url: 'api/user',
    method: 'get',
    params
  })
}

export function updatePass(user) {
  const data = {
    oldPassword: encrypt(user.oldPassword),
    newPassword: encrypt(user.newPassword)
  }
  return request({
    url: 'api/user/password',
    method: 'put',
    data
  })
}

export default {
  getDeptList(params) {
    return request({
      url: 'api/dept',
      method: 'get',
      params: params
    })
  },
  addDept(params) {
    return request({
      url: 'api/dept',
      method: 'post',
      data: params
    })
  },
  updataDept(params) {
    return request({
      url: 'api/dept',
      method: 'put',
      data: params
    })
  },
  deleteDept(codeId) {
    return request({
      url: "api/dept/" + codeId,
      method: "DELETE"
    });
  },
  //获取所有网点
  getSiteList(params) {
    return request({
      url: 'api/site/all',
      method: 'get',
      params: params
    })
  },
  //生成提车单
  generatePickNote(params) {
    return request({
      url: 'api/file/pick-record-contract',
      method: 'post',
      data: params
    })
  },
  addUser(params) {
    return request({
      url: 'api/user',
      method: 'post',
      data: params
    })
  },
  updataUser(params) {
    return request({
      url: 'api/user',
      method: 'put',
      data: params
    })
  },
  deleteUser(codeId) {
    return request({
      url: "api/user/" + codeId,
      method: "DELETE"
    });
  },
  //重置密码
  resetPass(params) {
    return request({
      url: 'api/user/reset-pwd',
      method: 'put',
      data: params
    })
  },
};
